<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      font-size: 20px;
    }
  </style>
</head>

<body>
  <div class="box" style="background-color:red;">
    我是box
  </div>

  <script>
    var boxEl = document.querySelector(".box")
    console.log(boxEl.style.backgroundColor)
    // 读取全部属性
    console.log(getComputedStyle(boxEl))
  </script>
</body>

</html>